﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;

namespace Royaumes_Libres.Database
{
    /// <summary>
    /// 
    /// </summary>
    /// <remarks>Patrick Chabot</remarks>
    public class cBuildingsBuilds
    {
        protected int pFkBuilding;
        protected int pRemainingWork;
        protected int pWorkUnite;

        public int PkBuilding { get { return this.pFkBuilding; } }
        public int RemainingWork { get { return this.pRemainingWork; } }
        public int WorkUnite { get { return this.pWorkUnite; } }

        protected cBuildingsBuilds() { }

        public static cBuildingsBuilds GetBuild(int PkKingdom)
        {
            cBuildingsBuilds build = new cBuildingsBuilds();
            SqlCommand cmd = cSQL.GetDbJeuCommand();

            cmd.CommandText = "[cde].[spGetBuildingsBuild]";
            cmd.Parameters.Add(cSQL.Param("@PkKingdom", PkKingdom, SqlDbType.Int));
            cmd.Connection.Open();

            SqlDataReader dr = cmd.ExecuteReader();
            
            dr.Read();

            build.pFkBuilding = dr.GetInt32(0);
            build.pRemainingWork = dr.GetInt32(1);
            build.pWorkUnite = dr.GetInt32(2);
            
            cmd.Connection.Close();

            return build;
        }
    }
}